package com.fh.config;

import com.gitee.Jmysy.binlog4j.core.BinlogEvent;
import com.gitee.Jmysy.binlog4j.core.IBinlogEventHandler;
import com.gitee.Jmysy.binlog4j.springboot.starter.annotation.BinlogSubscriber;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@BinlogSubscriber(clientName = "master")
public class UserEventHandler implements IBinlogEventHandler<Object> {

    @Override
    public void onInsert(BinlogEvent<Object> event) {
        log.info("插入数据：" + event.getData());
    }

    @Override
    public void onUpdate(BinlogEvent<Object> event) {
        log.info("修改数据:" + event.getData());
    }

    @Override
    public void onDelete(BinlogEvent<Object> event) {
        log.info("删除数据:" + event.getData());
    }

    @Override
    public boolean isHandle(String database, String table) {
        return database.equals("mystudy") && table.equals("a") || table.equals("student");

    }

}